const { defineConfig } = require('@vue/cli-service')
const AutoImport = require('unplugin-auto-import/webpack')
const Components = require('unplugin-vue-components/webpack')
const { ElementPlusResolver } = require('unplugin-vue-components/resolvers')
module.exports = defineConfig({
  transpileDependencies: true,
  devServer: {
    proxy: {
      
  "/api": { // 代理接口前缀为/bpi的请求
    "target": 'http://47.106.205.88/ms/', // 对应的代理地址
    "secure": false, // 接受运行在https上，默认不接受
    "changeOrigin": true, // 如果设置为true,那么本地会虚拟一个服务器接收你的请求并代你发送该请求，这样就不会有跨域问题（只适合开发环境）
    "pathRewrite": { //重写路径 比如'/apis/aaa/ccc'重写为'/aaa/ccc'
      '^/api': ""
    }
  
  
    }
  }
  },
  configureWebpack() {
    return{
      plugins: [
        AutoImport({
          imports: [
            'vue'
          ],
          resolvers: [ElementPlusResolver({ importStyle: false })]
        }),
        Components({
          resolvers: [ElementPlusResolver()],
        })
      ],
    
   
    }
  
  },
  chainWebpack:(config) =>{
    config.optimization.splitChunks({
      chunks: 'all',
      cacheGroups: {
     
        vue: {
          name: 'vue',
          test: /[\\/]node_modules[\\/](vue(.*)|core-js)[\\/]/,
          chunks: 'initial',
          priority: 20,
        },
        elementUI: {
          name: 'element-plus',
          test: /[\\/]node_modules[\\/]element-plus(.*)[\\/]/,
          priority: 30,
        }
    
    },
   
  }),
  config.externals({
     // CDN 的 Element 依赖全局变量 Vue， 所以 Vue 也需要使用 CDN 引入
   vue: 'Vue',
   'element-plus': 'ElementPlus',
   '@grapecity/spread-sheets': 'GC',
  //  '@grapecity/spread-sheets-vue': 'Menu',
  //  '@logicflow/extension/lib/Snapshot': 'Snapshot',
  })
  
},

})
